package com.jobjoin.jobjoin.user.controller;


import com.jobjoin.jobjoin.common.util.R;
import com.jobjoin.jobjoin.user.entity.Position;
import com.jobjoin.jobjoin.user.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 岗位表 一个企业可以发布多个岗位 前端控制器
 * </p>
 *
 * @author WinsomeC
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/user/position")
public class PositionController {
    @Autowired
    private PositionService positionService;

    @PostMapping("/addPosition")
    public R addPosition(Position position){
        boolean save = positionService.save(position);
        if(save){
            return R.ok();
        }else{
            return R.error();
        }
    }
    @GetMapping
    public R getPosition(){
        List<Position> list = positionService.list(null);
        return R.ok().data("items",list);
    }

    @DeleteMapping("{id}")
    public boolean deletePositionById(@PathVariable String id) {
        boolean b = positionService.removeById(id);
        return b;
    }
}

